package com.c6906.vdam.das.model.entity;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class VehiclesUnfixDetail {
    private String id;
    private String regionCode;
    private String regionName;
    private Long ownUnitId;
    private String ownUnitName;
    private Long useUnitId;
    private String useUnitName;
    private Long vehTypeId;
    private String vehTypeName;
    private Long vehPropId;
    private String vehPropName;
    private String vehPlateNum;
    private Long vehiclesCode;
    private String plateColorName;
    private String terminalSn;
    private String simCard;
    private Integer isFix;
    private Date startTime;
    private BigDecimal startLon;
    private BigDecimal startLat;
    private Date endTime;
    private BigDecimal endLon;
    private BigDecimal endLat;
    private Long duration;
    private Date createTime;
    private Date updateTime;
    private Integer status;
    private Integer isDeleted;

    public VehiclesUnfixDetail(TerminalData terminalData, TerminalBusinessInfo terminalBusinessInfo) {
        this.id = IdUtil.fastUUID();
        this.regionCode = terminalBusinessInfo.getRegionCode();
        this.regionName = terminalBusinessInfo.getRegionName();
        this.ownUnitId = NumberUtil.parseLong(terminalBusinessInfo.getOwnUnitId(), 0L);
        this.ownUnitName = terminalBusinessInfo.getOwnUnitName();
        this.useUnitId = NumberUtil.parseLong(terminalBusinessInfo.getUseUnitId(), 0L);
        this.useUnitName = terminalBusinessInfo.getUseUnitName();
        this.vehTypeId = NumberUtil.parseLong(terminalBusinessInfo.getVehTypeId(), 0L);
        this.vehTypeName = terminalBusinessInfo.getVehTypeName();
        this.vehPropId = NumberUtil.parseLong(terminalBusinessInfo.getVehPropId(), 0L);
        this.vehPropName = terminalBusinessInfo.getVehPropName();
        this.simCard = terminalBusinessInfo.getSimCard();
        this.vehPlateNum = terminalBusinessInfo.getVehPlateNum();
        this.vehiclesCode = NumberUtil.parseLong(terminalBusinessInfo.getVehiclesCode(), 0L);
        this.plateColorName = terminalBusinessInfo.getPlateColorName();
        this.terminalSn = terminalBusinessInfo.getTerminalSn();
        this.isFix = 0;
        this.startTime = DateUtil.parse(terminalData.getTerminalTime());
        this.startLon = NumberUtil.add(terminalData.getLongitude());
        this.startLat = NumberUtil.add(terminalData.getLatitude());
        this.createTime = DateUtil.date();
        this.status = 1;
        this.isDeleted = 0;
    }
}
